﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using HGZP.BLL;
using HGZP.Model;
using HGZP.PLL;
namespace SZCB.admin.FoodManager
{
    public partial class AddSubstance : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region 提交按钮

        /// <summary>
        /// 提交按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CSubstanceBLL myCSubstanceBLL = new CSubstanceBLL();
            DataTable dt = myCSubstanceBLL.F02_SelectHaveWhere("sName = '" + txtName.Text + "'");
            if (dt.Rows.Count > 0)
            {
                string strErrmessage = "该营养种类已添加";
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + strErrmessage + "');</script>");
                return;
            }
            CSubstance myCSubstance = new CSubstance();
            myCSubstance.sGuid = MyFunction.GetNewGuid();
            myCSubstance.sName = txtName.Text;
            myCSubstance.dCreateDate = DateTime.Now;
            if (!myCSubstanceBLL.F_Insert(myCSubstance))
            {
                string strErrmessage = "添加营养种类失败";
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + strErrmessage + "');</script>");
                return;
            }

        }
        #endregion


    }
}